package com.jie.controller;




import com.jie.dto.CommentDTO;
import com.jie.entity.Comment;
import com.jie.response.RespBean;
import com.jie.service.ICommentService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 论坛评论表 前端控制器
 * </p>
 *
 * @author jie
 * @since 2024-05-29
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论模块")
public class CommentController {
    @Autowired
    private ICommentService commentService;
    //查看评论
    @ApiOperation("查看指定评论")
    @GetMapping("/check/{commentId}")
    public RespBean<?> checkCommentById(@PathVariable("commentId") Integer commentId) {
        return RespBean.success("根据id查询指定评论",commentService.checkCommentById(commentId));
    }

    //删除评论
    @ApiOperation("删除指定评论")
    @GetMapping("/delete/{commentId}")
    public RespBean<Boolean>deleteCommentById(@RequestParam("commentId") Integer commentId) {
        return RespBean.success("根据id删除指定评论",commentService.deleteCommentById(commentId));
    }


    //新增评论(回复评论)
    @ApiOperation("新增评论")
    @PostMapping("/add")
    public RespBean<Boolean>addComment(@RequestBody CommentDTO commentDto) {

        return RespBean.success("新增评论",commentService.addComment(commentDto));
        //评论完可能需要跳转
    }

    //查询评论列表
    @ApiOperation("查询评论列表")
    @PostMapping("/list")
    public RespBean<Boolean>getCommentList() {
        return RespBean.success("获取评论列表成功",commentService.getCommentList());
    }
}

